import Vue from 'vue'
import Vuex from 'vuex'
import {getPlatformCode} from "~/interface/Common";
import auth from "./auth";

Vue.use(Vuex)
const state = {
    runData: '',
    endtTime: '',
    tailingNumber: '',
}
const mutations = {
    changeStart (state, payload) {
        state.runData = payload.startTime
        console.log(state.runData);
    },
    changeEnd (state, payload) {
        state.endtTime = payload.endtTime
        console.log(state.endtTime);
    },
    changeTailingNumber(state,payload){
        state.tailingNumber = payload.tailingNumber;
        localStorage.setItem("currentTailingNumber-"+getPlatformCode(), payload.tailingNumber.toString())
    }
}
const actions = {

}

const getters = {
    currentTailingNumber(state){
        const local = localStorage.getItem("currentTailingNumber-"+getPlatformCode());
        if(local!==state.tailingNumber) return local;
        return state.tailingNumber;
    }
}

export default new Vuex.Store({
    state,
    mutations,
    actions,
    getters,
    modules:{
        auth
    }
})
